package com.sun.jeecgexam.apache;

import com.sun.tools.internal.ws.resources.WebserviceapMessages;

import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;

/**
 * Created by sun on 2017/4/13.
 */
public class WebServer {

    public void startServer(int port) {

        try {
            ServerSocket serverSocket = new ServerSocket(port);
            while (true) {
                Socket socket = serverSocket.accept();
                new Processor(socket).run();
            }
        } catch (IOException e) {
            e.printStackTrace();
        }

    }


    public static void main(String[] args) {
        int port = 8088;

        if (args.length == 1) {

            port = Integer.parseInt(args[0]);
        }


        new WebServer().startServer(port);

    }
}
